<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="售后订单" prop="code">
        <el-input
          v-model="queryParams.code"
          placeholder="请输入售后订单"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="来源系统" prop="srcsys">
        <el-input
          v-model="queryParams.srcsys"
          placeholder="请输入来源系统"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
<!--      <el-form-item label="销售订单号" prop="refordercode">-->
<!--        <el-input-->
<!--          v-model="queryParams.refordercode"-->
<!--          placeholder="请输入销售订单号"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="来源平台" prop="sourceplatformcode">-->
<!--        <el-input-->
<!--          v-model="queryParams.sourceplatformcode"-->
<!--          placeholder="请输入来源平台"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="来源类型" prop="sourcetype">-->
<!--        <el-input-->
<!--          v-model="queryParams.sourcetype"-->
<!--          placeholder="请输入来源类型"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="事务类型编码" prop="transactiontype">-->
<!--        <el-input-->
<!--          v-model="queryParams.transactiontype"-->
<!--          placeholder="请输入事务类型编码"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
      <el-form-item label="下单日期" prop="tradecreatedat">
        <el-date-picker
          v-model="daterangeTradecreatedat"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="实际入库日期" prop="closeat">
        <el-date-picker
          v-model="daterangeCloseat"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
<!--      <el-form-item label="售后成本中心编码" prop="salescostcentercode">-->
<!--        <el-input-->
<!--          v-model="queryParams.salescostcentercode"-->
<!--          placeholder="请输入售后成本中心编码"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="售后成本中心名称" prop="salescostcentername">-->
<!--        <el-input-->
<!--          v-model="queryParams.salescostcentername"-->
<!--          placeholder="请输入售后成本中心名称"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
      <el-form-item label="售后单位编码" prop="customercode">
        <el-input
          v-model="queryParams.customercode"
          placeholder="请输入售后单位编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="售后单位名称" prop="customername">
        <el-input
          v-model="queryParams.customername"
          placeholder="请输入售后单位名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
<!--      <el-form-item label="退出仓库编码" prop="exitwarehousecode">-->
<!--        <el-input-->
<!--          v-model="queryParams.exitwarehousecode"-->
<!--          placeholder="请输入退出仓库编码"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="退出仓库名称" prop="exitwarehousename">-->
<!--        <el-input-->
<!--          v-model="queryParams.exitwarehousename"-->
<!--          placeholder="请输入退出仓库名称"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
      <el-form-item label="开票组织编码" prop="invoicecode">
        <el-input
          v-model="queryParams.invoicecode"
          placeholder="请输入开票组织编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="开票组织名称" prop="invoicename">
        <el-input
          v-model="queryParams.invoicename"
          placeholder="请输入开票组织名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
<!--      <el-form-item label="备注" prop="hasnote">-->
<!--        <el-input-->
<!--          v-model="queryParams.hasnote"-->
<!--          placeholder="请输入备注"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="币别" prop="currency">-->
<!--        <el-input-->
<!--          v-model="queryParams.currency"-->
<!--          placeholder="请输入币别"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="汇率" prop="exchangerate">-->
<!--        <el-input-->
<!--          v-model="queryParams.exchangerate"-->
<!--          placeholder="请输入汇率"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="创建时间" prop="createtime">-->
<!--        <el-date-picker clearable-->
<!--                        v-model="queryParams.createtime"-->
<!--                        type="date"-->
<!--                        value-format="yyyy-MM-dd"-->
<!--                        placeholder="请选择创建时间">-->
<!--        </el-date-picker>-->
<!--      </el-form-item>-->
      <el-form-item label="生成下游单据状态" prop="iscreatebill">
        <el-select v-model="queryParams.iscreatebill" placeholder="请选择生成下游单据状态" clearable>
          <el-option
            style="width: 215px"
            v-for="dict in dict.type.settlement_bill_push_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="生成外部销售单状态" prop="iscreateoutbill">
        <el-select v-model="queryParams.iscreateoutbill" placeholder="请选择生成外部销售单状态" clearable>
          <el-option
            style="width: 215px"
            v-for="dict in dict.type.settlement_bill_push_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>

      <el-form-item label="退货类型" prop="returntype">
        <el-select v-model="queryParams.returntype" placeholder="请选择生成外部销售单状态" clearable>
          <el-option
            style="width: 215px"
            v-for="dict in dict.type.settlement_return_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
<!--      <el-form-item label="失败原因" prop="reason">-->
<!--        <el-input-->
<!--          v-model="queryParams.reason"-->
<!--          placeholder="请输入失败原因"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['settlementCenter/basebill:salereturnbill:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['settlementCenter/basebill:salereturnbill:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['settlementCenter/basebill:salereturnbill:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['settlementCenter/basebill:salereturnbill:export']"
        >导出</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          plain
          type="info"
          size="mini"
          :disabled="single"
          @click="handleGetDown"
          v-hasPermi="['settlementCenter/basebill:transferbill:query']"
        >下查
        </el-button>
      </el-col>
<!--      <el-col :span="1.5">-->
<!--        <el-button-->
<!--          type="primary"-->
<!--          plain-->
<!--          size="mini"-->
<!--          :disabled="multiple"-->
<!--          @click="StartPush"-->
<!--          v-hasPermi="['settlementCenter/basebill:transferbill:remove']"-->
<!--        >下发</el-button>-->
<!--      </el-col>-->
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="salereturnbillList"
              height="600px"
              ref="serveTable" @row-click="rowClick"
              :row-class-name="rowBillHeadIndex"
              @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
<!--      <el-table-column label="id" align="center" prop="id" />-->
      <el-table-column label="序号" align="center" prop="index" />
      <el-table-column label="售后订单" align="center" prop="code" />
      <el-table-column label="来源系统" align="center" prop="srcsys" />
      <el-table-column label="销售订单号" align="center" prop="refordercode" />
      <el-table-column label="来源上游平台" align="center" prop="sourceplatformcode">
<!--        <template slot-scope="scope">-->
<!--          <dict-tag :options="dict.type.srcup_type" :value="scope.row.sourceplatformcode"/>-->
<!--        </template>-->
      </el-table-column>
      <el-table-column label="来源上游单号" align="center" prop="sourceordercode" />
      <el-table-column label="来源类型" align="center" prop="sourcetype" />
      <el-table-column label="事务类型编码" align="center" prop="transactiontype" />
      <el-table-column label="下单日期" align="center" prop="tradecreatedat" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.tradecreatedat, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="实际入库时间" align="center" prop="closeat" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.closeat, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="售后成本中心编码" align="center" prop="salescostcentercode" />
      <el-table-column label="售后成本中心名称" align="center" prop="salescostcentername" />
      <el-table-column label="售后单位编码" align="center" prop="customercode" />
      <el-table-column label="售后单位名称" align="center" prop="customername" />
      <el-table-column label="退出仓库编码" align="center" prop="exitwarehousecode" />
      <el-table-column label="退出仓库名称" align="center" prop="exitwarehousename" />
      <el-table-column label="开票组织编码" align="center" prop="invoicecode" />
      <el-table-column label="开票组织名称" align="center" prop="invoicename" />
      <el-table-column label="备注" align="center" prop="hasnote" />
      <el-table-column label="币别" align="center" prop="currency" />
      <el-table-column label="汇率" align="center" prop="exchangerate" />
      <el-table-column label="创建时间" align="center" prop="createtime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createtime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
<!--      <el-table-column label="是否生成下游单据" align="center" prop="iscreatebill" />-->
      <el-table-column label="是否生成下游单据" align="center" prop="iscreatebill">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.settlement_bill_push_type" :value="scope.row.iscreatebill"/>
        </template>
      </el-table-column>
      <el-table-column label="失败原因" align="center" prop="reason" :show-overflow-tooltip="true" />
      <el-table-column label="生成外部销售单状态" align="center" prop="iscreateoutbill">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.settlement_bill_push_type" :value="scope.row.iscreateoutbill"/>
        </template>
      </el-table-column>

      <el-table-column label="退货类型" align="center" prop="returntype">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.settlement_return_type" :value="scope.row.returntype"/>
        </template>
      </el-table-column>
      <el-table-column label="外部销售单失败原因" align="center" prop="outreason" :show-overflow-tooltip="true" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click.native.stop="handleUpdate(scope.row)"
            v-hasPermi="['settlementCenter/basebill:salereturnbill:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click.native.stop="handleDelete(scope.row)"
            v-hasPermi="['settlementCenter/basebill:salereturnbill:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改OMS销售退货单对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
        <el-row>
          <el-col :span="6">
            <el-form-item label="售后订单" prop="code">
              <el-input v-model="form.code" placeholder="请输入售后订单" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="销售订单号" prop="refordercode">
              <el-input v-model="form.refordercode" placeholder="请输入销售订单号" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="来源系统" prop="srcsys">
              <el-input v-model="form.srcsys" placeholder="请输入来源系统" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="来源类型" prop="sourcetype">
              <el-input v-model="form.sourcetype" placeholder="请输入来源类型" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>

          <el-col :span="6">
            <el-form-item label="事务类型编码" prop="transactiontype">
              <el-input v-model="form.transactiontype" placeholder="请输入事务类型编码" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="下单日期" prop="tradecreatedat">
              <el-date-picker clearable
                              v-model="form.tradecreatedat"
                              type="date"
                              value-format="yyyy-MM-dd"
                              placeholder="请选择下单日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="实际入库日期" prop="closeat">
              <el-date-picker clearable
                              v-model="form.closeat"
                              type="date"
                              value-format="yyyy-MM-dd"
                              placeholder="请选择实际入库日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="售后成本中心编码" prop="salescostcentercode">
              <el-input v-model="form.salescostcentercode" placeholder="请输入售后成本中心编码" />
            </el-form-item>
          </el-col>

        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="售后成本中心名称" prop="salescostcentername">
              <el-input v-model="form.salescostcentername" placeholder="请输入售后成本中心名称" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="售后单位编码" prop="customercode">
              <el-input v-model="form.customercode" placeholder="请输入售后单位编码" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="售后单位名称" prop="customername">
              <el-input v-model="form.customername" placeholder="请输入售后单位名称" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="退出仓库编码" prop="exitwarehousecode">
              <el-input v-model="form.exitwarehousecode" placeholder="请输入退出仓库编码" />
            </el-form-item>
          </el-col>

        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="退出仓库名称" prop="exitwarehousename">
              <el-input v-model="form.exitwarehousename" placeholder="请输入退出仓库名称" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="开票组织编码" prop="invoicecode">
              <el-input v-model="form.invoicecode" placeholder="请输入开票组织编码" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="开票组织名称" prop="invoicename">
              <el-input v-model="form.invoicename" placeholder="请输入开票组织名称" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="备注" prop="hasnote">
              <el-input v-model="form.hasnote" placeholder="请输入备注" />
            </el-form-item>
          </el-col>

        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="币别" prop="currency">
              <el-input v-model="form.currency" placeholder="请输入币别" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="汇率" prop="exchangerate">
              <el-input v-model="form.exchangerate" placeholder="请输入汇率" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="来源上游平台" prop="sourceplatformcode">
<!--              <el-select v-model="form.sourceplatformcode" placeholder="请选择来源上游平台">-->
<!--                <el-option-->
<!--                  v-for="dict in dict.type.srcup_type"-->
<!--                  :key="dict.value"-->
<!--                  :label="dict.label"-->
<!--                  :value="dict.value"-->
<!--                ></el-option>-->
<!--              </el-select>-->

              <el-input v-model="form.sourceplatformcode" placeholder="请输入来源上游单号" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="来源上游单号" prop="sourceordercode">
              <el-input v-model="form.sourceordercode" placeholder="请输入来源上游单号" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="生成下游单据状态" prop="iscreatebill">
              <el-select v-model="form.iscreatebill" placeholder="请选择生成下游单据状态">
                <el-option
                  v-for="dict in dict.type.settlement_bill_push_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="Number(dict.value)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="18">
            <el-form-item label="失败原因" prop="reason">
              <el-input v-model="form.reason" type="textarea" autosize />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="生成外部销售单状态" prop="iscreateoutbill">
              <el-select v-model="form.iscreateoutbill" placeholder="请选择生成外部销售单状态">
                <el-option
                  v-for="dict in dict.type.settlement_bill_push_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="Number(dict.value)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="18">
            <el-form-item label="外部销售单失败原因" prop="outreason">
              <el-input v-model="form.outreason" type="textarea" autosize/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="退货类型" prop="returntype">
              <el-select v-model="form.returntype" placeholder="">
                <el-option
                  v-for="dict in dict.type.settlement_return_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-divider content-position="center">OMS销售退货单分录信息</el-divider>
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAddOmsSalereturnbillentry">添加</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDeleteOmsSalereturnbillentry">删除</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button type="danger" icon="el-icon-plus" size="mini" @click="importTemplate">下载导入模板</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button type="danger" icon="el-icon-plus" size="mini" @click="importExcelsalereturnbillEntry">导入数据</el-button>
          </el-col>
        </el-row>
        <el-table :data="omsSalereturnbillentryList" :row-class-name="rowOmsSalereturnbillentryIndex" @selection-change="handleOmsSalereturnbillentrySelectionChange" ref="omsSalereturnbillentry"
                  max-height="500px"
        >
          <el-table-column type="selection" width="50" align="center" />
          <el-table-column label="序号" align="center" prop="index" width="50"/>
          <el-table-column label="项次" prop="lineno" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.lineno" placeholder="请输入项次" />
            </template>
          </el-table-column>
          <el-table-column label="商品编号" prop="skucode" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.skucode" placeholder="请输入商品编号" />
            </template>
          </el-table-column>
          <el-table-column label="商品名称" prop="skuname" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.skuname" placeholder="请输入商品名称" />
            </template>
          </el-table-column>
          <el-table-column label="售后数量" prop="qty" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.qty" placeholder="请输入售后数量" />
            </template>
          </el-table-column>
          <el-table-column label="计量单位编码" prop="unit" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.unit" placeholder="请输入计量单位编码" />
            </template>
          </el-table-column>
          <el-table-column label="基本售后数量" prop="baseqty" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.baseqty" placeholder="请输入基本售后数量" />
            </template>
          </el-table-column>
          <el-table-column label="基本计量单位" prop="baseunit" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.baseunit" placeholder="请输入基本计量单位" />
            </template>
          </el-table-column>
          <el-table-column label="品控承担数量" prop="qualityundertakeqty" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.qualityundertakeqty" placeholder="请输入品控承担数量" />
            </template>
          </el-table-column>
          <el-table-column label="品控拒绝处理数量" prop="qualityrefuseqty" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.qualityrefuseqty" placeholder="请输入品控拒绝处理数量" />
            </template>
          </el-table-column>
          <el-table-column label="仓库承担待收数量" prop="warehouseundertakeqty" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.warehouseundertakeqty" placeholder="请输入仓库承担待收数量" />
            </template>
          </el-table-column>
          <el-table-column label="仓库拒绝处理数量" prop="warehouserefuseqty" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.warehouserefuseqty" placeholder="请输入仓库拒绝处理数量" />
            </template>
          </el-table-column>
          <el-table-column label="仓库承担无实物数量" prop="warehousenoneqty" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.warehousenoneqty" placeholder="请输入仓库承担无实物数量" />
            </template>
          </el-table-column>
          <el-table-column label="确认数量" prop="confirmquantity" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.confirmquantity" placeholder="请输入确认数量" />
            </template>
          </el-table-column>
          <el-table-column label="退入仓库编码" prop="returnwarehousecode" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.returnwarehousecode" placeholder="请输入退入仓库编码" />
            </template>
          </el-table-column>
          <el-table-column label="退入仓库名称" prop="returnwarehousename" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.returnwarehousename" placeholder="请输入退入仓库名称" />
            </template>
          </el-table-column>
          <el-table-column label="虚拟退货仓库编码" prop="virtualreturnwarehousecode" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.virtualreturnwarehousecode" placeholder="请输入虚拟退货仓库编码" />
            </template>
          </el-table-column>
          <el-table-column label="虚拟退货仓库名称" prop="virtualreturnwarehousename" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.virtualreturnwarehousename" placeholder="请输入虚拟退货仓库名称" />
            </template>
          </el-table-column>
          <el-table-column label="客户订单号" prop="customerorder" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.customerorder" placeholder="请输入客户订单号" />
            </template>
          </el-table-column>
          <el-table-column label="装车单号" prop="despatchcargono" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.despatchcargono" placeholder="请输入装车单号" />
            </template>
          </el-table-column>
          <el-table-column label="售后类型" prop="internalordertype" width="150">
            <template slot-scope="scope">
              <el-select v-model="scope.row.internalordertype" placeholder="请选择售后类型">
                <el-option label="请选择字典生成" value="" />
              </el-select>
            </template>
          </el-table-column>
          <el-table-column label="售后日期" prop="refundcreatedat" width="240">
            <template slot-scope="scope">
              <el-date-picker clearable v-model="scope.row.refundcreatedat" type="date" value-format="yyyy-MM-dd" placeholder="请选择售后日期" />
            </template>
          </el-table-column>
          <el-table-column label="不含税单价" prop="notaxprice" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.notaxprice" placeholder="请输入不含税单价" />
            </template>
          </el-table-column>
          <el-table-column label="不含税总金额" prop="notaxamount" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.notaxamount" placeholder="请输入不含税总金额" />
            </template>
          </el-table-column>
          <el-table-column label="系统含税单价" prop="systaxprice" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.systaxprice" placeholder="请输入系统含税单价" />
            </template>
          </el-table-column>
          <el-table-column label="含税单价" prop="taxprice" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.taxprice" placeholder="请输入含税单价" />
            </template>
          </el-table-column>
          <el-table-column label="含税总金额" prop="taxamount" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.taxamount" placeholder="请输入含税总金额" />
            </template>
          </el-table-column>
          <el-table-column label="税率" prop="taxrate" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.taxrate" placeholder="请输入税率" />
            </template>
          </el-table-column>
          <el-table-column label="税额" prop="tax" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.tax" placeholder="请输入税额" />
            </template>
          </el-table-column>
          <el-table-column label="是否赠品" prop="isgift" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.isgift" placeholder="请输入是否赠品" />
            </template>
          </el-table-column>
          <el-table-column label="备注" prop="remark" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.remark" placeholder="请输入备注" />
            </template>
          </el-table-column>
          <el-table-column label="发生日期" prop="occurrencedate" width="240">
            <template slot-scope="scope">
              <el-date-picker clearable v-model="scope.row.occurrencedate" type="date" value-format="yyyy-MM-dd" placeholder="请选择发生日期" />
            </template>
          </el-table-column>
          <el-table-column label="生产日期" prop="productiondate" width="240">
            <template slot-scope="scope">
              <el-date-picker clearable v-model="scope.row.productiondate" type="date" value-format="yyyy-MM-dd" placeholder="请选择生产日期" />
            </template>
          </el-table-column>
        </el-table>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 打开下游单据对话框 -->
    <el-dialog :title="title" :visible.sync="openDown" width="1400px"
               append-to-body>
      <el-form :rules="rules" label-width="100px">
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="info"
              plain
              size="mini"
              suffix-icon="icon el-icon-search"
              @click="getRowDownBillInfo"
              :disabled="single1"
            >查看详情
            </el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button
              plain
              type="danger"
              size="mini"
              icon="el-icon-delete"
              @click="delAllDown"
            >删除所有下游单据
            </el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button
              plain
              @click="cancelDown"
              size="mini">退 出
            </el-button>
          </el-col>
        </el-row>
        <el-table
          :data="omsDownBillList"
          :row-class-name="rowBillHeadIndex"
          @selection-change="handleOmsBillSelectionChange"
          @row-click="rowDownClick"
          ref="serveDown">
          <el-table-column type="selection" width="50" align="center"/>
          <el-table-column label="序号" align="center" prop="index" width="50"/>
          <el-table-column label="单据类型" align="center" prop="billtype" width="150"/>
          <el-table-column label="单据编号" align="center" prop="billnumber" width="210"/>
          <el-table-column label="业务日期" align="center" prop="bizdate" width="125"></el-table-column>
          <el-table-column label="库存组织编码" align="center" prop="sournumber" width="150"></el-table-column>
          <el-table-column label="库存组织名称" prop="sourname" width="150"></el-table-column>
          <el-table-column label="对方编码" prop="targetnumber" width="150"></el-table-column>
          <el-table-column label="对方名称" align="center" prop="targetname" width="150"></el-table-column>
          <el-table-column label="汇总单号" prop="sumbillnumber" width="150"></el-table-column>
        </el-table>
      </el-form>
    </el-dialog>

    <!-- 打开销售出库单对话框 -->
    <el-dialog :title="title" :visible.sync="openSal" width="1500px" append-to-body>
      <el-form ref="formSal" :model="formSal" :rules="rules" label-width="100px">
        <el-row>
          <el-col :span="6">
            <el-form-item label="单据编号" prop="billnumber">
              <el-input v-model="formSal.billnumber" placeholder="请输入单据编号"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="业务日期" prop="bizdate">
              <el-date-picker clearable
                              style="width: 265px"
                              v-model="formSal.bizdate"
                              type="date"
                              value-format="yyyy-MM-dd"
                              placeholder="请选择业务日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="库存组织编码" prop="storageorgnumber">
              <el-input v-model="formSal.storageorgnumber" placeholder="请输入库存组织编码"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="库存组织名称" prop="storageorgname">
              <el-input v-model="formSal.storageorgname" placeholder="请输入库存组织名称"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="业务类型编码" prop="biztypenumber">
              <el-input v-model="formSal.biztypenumber" placeholder="请输入业务类型编码"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="业务类型名称" prop="biztypename">
              <el-input v-model="formSal.biztypename" placeholder="请输入业务类型名称"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="事务类型编码" prop="transactiontypenumber">
              <el-input v-model="formSal.transactiontypenumber" placeholder="请输入事务类型编码"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="事务类型名称" prop="transactiontypename">
              <el-input v-model="formSal.transactiontypename" placeholder="请输入事务类型名称"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="送货客户编码" prop="customernumber">
              <el-input v-model="formSal.customernumber" placeholder="请输入送货客户编码"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="送货客户名称" prop="customername">
              <el-input v-model="formSal.customername" placeholder="请输入送货客户名称"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="记账公司编码" prop="accountcompanynumber">
              <el-input v-model="formSal.accountcompanynumber" placeholder="请输入记账公司编码"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="记账公司名称" prop="accountcompanyname">
              <el-input v-model="formSal.accountcompanyname" placeholder="请输入记账公司名称"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="成本中心编码" prop="costcenternumber">
              <el-input v-model="formSal.costcenternumber" placeholder="请输入成本中心编码"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="成本中心名称" prop="costcentername">
              <el-input v-model="formSal.costcentername" placeholder="请输入成本中心名称"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="币别" prop="currency">
              <el-input v-model="formSal.currency" placeholder="请输入币别"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="汇率" prop="exchangerate">
              <el-input v-model="formSal.exchangerate" placeholder="请输入汇率"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="备注" prop="description">
              <el-input v-model="formSal.description" placeholder="请输入备注"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="客户订单号" prop="customerorderno">
              <el-input v-model="formSal.customerorderno" placeholder="请输入客户订单号"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="厂编" prop="factorymake">
              <el-input v-model="formSal.factorymake" placeholder="请输入厂编"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="来源单据类型" prop="srcbilltype">
              <el-input v-model="formSal.srcbilltype" placeholder="请输入来源单据类型"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="来源单据编号" prop="srcbillnumber">
              <el-input v-model="formSal.srcbillnumber" placeholder="请输入来源单据编号"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="是否外部客户" prop="isoutcustomer">
              <el-input v-model="formSal.isoutcustomer" placeholder="请输入是否外部客户"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="汇总单据编号" prop="sumbillnumber">
              <el-input v-model="formSal.sumbillnumber" placeholder="请输入汇总单据编号"/>
            </el-form-item>
          </el-col>

          <el-col :span="6">
            <el-form-item label="传送日期" prop="transtime">
              <el-date-picker clearable
                              style="width: 265px"
                              v-model="formSal.transtime"
                              type="date"
                              value-format="yyyy-MM-dd"
                              placeholder="请选择传送日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="已传EAS" prop="istrans">
              <el-select v-model="formSal.istrans" placeholder="请选择是否已传EAS">
                <el-option
                  v-for="dict in dict.type.yes_no"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="18">
            <el-form-item label="失败原因" prop="reason">
              <el-input v-model="formSal.reason" type="textarea" autosize/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-divider content-position="center">销售出库单明细信息</el-divider>
        <el-table
          :data="omsSaleissuebillentryList"
          ref="omsSaleissuebillentry"
          max-height="500px"
        >
          <el-table-column type="selection" width="50" align="center"/>
          <el-table-column label="序号" align="center" prop="index" width="50"/>
          <el-table-column label="仓库编码" prop="warehousenumber" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.warehousenumber" placeholder="请输入仓库编码"/>
            </template>
          </el-table-column>
          <el-table-column label="仓库名称" prop="warehousename" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.warehousename" placeholder="请输入仓库名称"/>
            </template>
          </el-table-column>
          <el-table-column label="物料编码" prop="materialnumber" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.materialnumber" placeholder="请输入物料编码"/>
            </template>
          </el-table-column>
          <el-table-column label="物料名称" prop="materialname" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.materialname" placeholder="请输入物料名称"/>
            </template>
          </el-table-column>
          <el-table-column label="计量单位" prop="unitnumber" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.unitnumber" placeholder="请输入计量单位"/>
            </template>
          </el-table-column>
          <el-table-column label="基本计量单位" prop="baseunitnumber" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.baseunitnumber" placeholder="请输入基本计量单位"/>
            </template>
          </el-table-column>
          <el-table-column label="数量" prop="qty" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.qty" placeholder="请输入数量"/>
            </template>
          </el-table-column>
          <el-table-column label="基本单位数量" prop="baseqty" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.baseqty" placeholder="请输入基本单位数量"/>
            </template>
          </el-table-column>
          <el-table-column label="单价" prop="price" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.price" placeholder="请输入单价"/>
            </template>
          </el-table-column>
          <el-table-column label="税率" prop="taxrate" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.taxrate" placeholder="请输入税率"/>
            </template>
          </el-table-column>
          <el-table-column label="系统含税单价" prop="systaxprice" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.systaxprice" placeholder="请输入系统含税单价"/>
            </template>
          </el-table-column>
          <el-table-column label="含税单价" prop="taxprice" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.taxprice" placeholder="请输入含税单价"/>
            </template>
          </el-table-column>
          <el-table-column label="金额" prop="amount" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.amount" placeholder="请输入金额"/>
            </template>
          </el-table-column>
          <el-table-column label="税额" prop="tax" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.tax" placeholder="请输入税额"/>
            </template>
          </el-table-column>
          <el-table-column label="价税合计" prop="taxamount" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.taxamount" placeholder="请输入价税合计"/>
            </template>
          </el-table-column>
          <el-table-column label="是否赠品" prop="ispresent" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.ispresent" placeholder="请输入是否赠品"/>
            </template>
          </el-table-column>
          <el-table-column label="备注" prop="remark" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.remark" placeholder="请输入备注"/>
            </template>
          </el-table-column>

          <el-table-column label="客户订单号" prop="customerOrderNo" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.customerOrderNo" placeholder="请输入客户订单号"/>
            </template>
          </el-table-column>
        </el-table>
      </el-form>
    </el-dialog>

    <!-- 打开采购入库单对话框 -->
    <el-dialog :title="title" :visible.sync="openPur" width="1500px" append-to-body>
      <el-form ref="formPur" :model="formPur" :rules="rules" label-width="100px">
        <el-row>
          <el-col :span="6">
            <el-form-item label="单据编号" prop="billnumber">
              <el-input v-model="formPur.billnumber" placeholder="请输入单据编号"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="业务日期" prop="bizdate">
              <el-date-picker clearable
                              style="width: 265px"
                              v-model="formPur.bizdate"
                              type="date"
                              value-format="yyyy-MM-dd"
                              placeholder="请选择业务日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="库存组织编码" prop="storageorgnumber">
              <el-input v-model="formPur.storageorgnumber" placeholder="请输入库存组织编码"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="库存组织名称" prop="storageorgname">
              <el-input v-model="formPur.storageorgname" placeholder="请输入库存组织名称"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="业务类型编码" prop="biztypenumber">
              <el-input v-model="formPur.biztypenumber" placeholder="请输入业务类型编码"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="业务类型名称" prop="biztypename">
              <el-input v-model="formPur.biztypename" placeholder="请输入业务类型名称"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="事务类型编码" prop="transactiontypenumber">
              <el-input v-model="formPur.transactiontypenumber" placeholder="请输入事务类型编码"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="事务类型名称" prop="transactiontypename">
              <el-input v-model="formPur.transactiontypename" placeholder="请输入事务类型名称"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="供应商编码" prop="suppliernumber">
              <el-input v-model="formPur.suppliernumber" placeholder="请输入供应商编码"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="供应商名称" prop="suppliername">
              <el-input v-model="formPur.suppliername" placeholder="请输入供应商名称"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="记账公司编码" prop="accountcompanynumber">
              <el-input v-model="formPur.accountcompanynumber" placeholder="请输入记账公司编码"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="记账公司名称" prop="accountcompanyname">
              <el-input v-model="formPur.accountcompanyname" placeholder="请输入记账公司名称"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="成本中心编码" prop="costcenternumber">
              <el-input v-model="formPur.costcenternumber" placeholder="请输入成本中心编码"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="成本中心名称" prop="costcentername">
              <el-input v-model="formPur.costcentername" placeholder="请输入成本中心名称"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="币别" prop="currency">
              <el-input v-model="formPur.currency" placeholder="请输入币别"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="汇率" prop="exchangerate">
              <el-input v-model="formPur.exchangerate" placeholder="请输入汇率"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="参考信息" prop="description">
              <el-input v-model="formPur.description" placeholder="请输入参考信息"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="来源单据类型" prop="srcbilltype">
              <el-input v-model="formPur.srcbilltype" placeholder="请输入来源单据类型"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="来源单据编号" prop="srcbillnumber">
              <el-input v-model="formPur.srcbillnumber" placeholder="请输入来源单据编号"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="汇总单据编号" prop="sumbillnumber">
              <el-input v-model="form.sumbillnumber" placeholder="请输入汇总单据编号"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-divider content-position="center">采购入库单明细信息</el-divider>
        <el-table :data="omsPurinwarehsbillentryList" ref="omsPurinwarehsbillentry">
          <el-table-column type="selection" width="50" align="center"/>
          <el-table-column label="序号" align="center" prop="index" width="50"/>
          <el-table-column label="仓库编码" prop="warehousenumber" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.warehousenumber" placeholder="请输入仓库编码"/>
            </template>
          </el-table-column>
          <el-table-column label="仓库名称" prop="warehousename" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.warehousename" placeholder="请输入仓库名称"/>
            </template>
          </el-table-column>
          <el-table-column label="物料编码" prop="materialnumber" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.materialnumber" placeholder="请输入物料编码"/>
            </template>
          </el-table-column>
          <el-table-column label="物料名称" prop="materialname" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.materialname" placeholder="请输入物料名称"/>
            </template>
          </el-table-column>
          <el-table-column label="计量单位" prop="unitnumber" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.unitnumber" placeholder="请输入计量单位"/>
            </template>
          </el-table-column>
          <el-table-column label="基本计量单位" prop="baseunitnumber" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.baseunitnumber" placeholder="请输入基本计量单位"/>
            </template>
          </el-table-column>
          <el-table-column label="数量" prop="qty" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.qty" placeholder="请输入数量"/>
            </template>
          </el-table-column>
          <el-table-column label="基本单位数量" prop="baseqty" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.baseqty" placeholder="请输入基本单位数量"/>
            </template>
          </el-table-column>
          <el-table-column label="单价" prop="price" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.price" placeholder="请输入单价"/>
            </template>
          </el-table-column>
          <el-table-column label="税率" prop="taxrate" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.taxrate" placeholder="请输入税率"/>
            </template>
          </el-table-column>
          <el-table-column label="含税单价" prop="taxprice" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.taxprice" placeholder="请输入含税单价"/>
            </template>
          </el-table-column>
          <el-table-column label="金额" prop="amount" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.amount" placeholder="请输入金额"/>
            </template>
          </el-table-column>
          <el-table-column label="税额" prop="tax" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.tax" placeholder="请输入税额"/>
            </template>
          </el-table-column>
          <el-table-column label="价税合计" prop="taxamount" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.taxamount" placeholder="请输入价税合计"/>
            </template>
          </el-table-column>
          <el-table-column label="是否赠品" prop="ispresent" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.ispresent" placeholder="请输入是否赠品"/>
            </template>
          </el-table-column>
          <el-table-column label="备注" prop="remark" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.remark" placeholder="请输入备注"/>
            </template>
          </el-table-column>
        </el-table>
      </el-form>
    </el-dialog>

    <!-- 打开库存调拨单对话框 -->
    <el-dialog :title="title" :visible.sync="openStock" width="1500px" append-to-body>
      <el-form ref="formStock" :model="formStock" :rules="rules" label-width="100px">
        <el-row>
          <el-col :span="6">
            <el-form-item label="单据编号" prop="billnumber">
              <el-input v-model="formStock.billnumber" placeholder="请输入单据编号"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="业务日期" prop="bizdate">
              <el-date-picker clearable
                              style="width: 265px"
                              v-model="formStock.bizdate"
                              type="date"
                              value-format="yyyy-MM-dd"
                              placeholder="请选择业务日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="业务类型编码" prop="biztypenumber">
              <el-input v-model="formStock.biztypenumber" placeholder="请输入业务类型编码"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="业务类型名称" prop="biztypename">
              <el-input v-model="formStock.biztypename" placeholder="请输入业务类型名称"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="调出库存组织编码" prop="issuestorageorgnumber">
              <el-input v-model="formStock.issuestorageorgnumber" placeholder="请输入调出库存组织编码"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="调出库存组织名称" prop="issuestorageorgname">
              <el-input v-model="formStock.issuestorageorgname" placeholder="请输入调出库存组织名称"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="调入库存组织编码" prop="receiptstorageorgnumber">
              <el-input v-model="formStock.receiptstorageorgnumber" placeholder="请输入调入库存组织编码"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="调入库存组织名称" prop="receiptstorageorgname">
              <el-input v-model="formStock.receiptstorageorgname" placeholder="请输入调入库存组织名称"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="调出成本中心编码" prop="outcostcenternumber">
              <el-input v-model="formStock.outcostcenternumber" placeholder="请输入调出成本中心编码"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="调出成本中心名称" prop="outcostcentername">
              <el-input v-model="formStock.outcostcentername" placeholder="请输入调出成本中心名称"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="调出记账公司编码" prop="outaccountcompanynumber">
              <el-input v-model="formStock.outaccountcompanynumber" placeholder="请输入调出记账公司编码"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="调出记账公司名称" prop="outaccountcompanyname">
              <el-input v-model="formStock.outaccountcompanyname" placeholder="请输入调出记账公司名称"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="调入成本中心编码" prop="incostcenternumber">
              <el-input v-model="formStock.incostcenternumber" placeholder="请输入调入成本中心编码"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="调入成本中心名称" prop="incostcentername">
              <el-input v-model="formStock.incostcentername" placeholder="请输入调入成本中心名称"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="调入记账公司编码" prop="inaccountcompanynumber">
              <el-input v-model="formStock.inaccountcompanynumber" placeholder="请输入调入记账公司编码"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="调入记账公司名称" prop="inaccountcompanyname">
              <el-input v-model="formStock.inaccountcompanyname" placeholder="请输入调入记账公司名称"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="币别" prop="currency">
              <el-input v-model="formStock.currency" placeholder="请输入币别"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="汇率" prop="exchangerate">
              <el-input v-model="formStock.exchangerate" placeholder="请输入汇率"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="参考信息" prop="description">
              <el-input v-model="formStock.description" placeholder="请输入参考信息"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="来源单据类型" prop="srcbilltype">
              <el-input v-model="formStock.srcbilltype" placeholder="请输入来源单据类型"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="来源单据编号" prop="srcbillnumber">
              <el-input v-model="formStock.srcbillnumber" placeholder="请输入来源单据编号"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="汇总单据编号" prop="sumbillnumber">
              <el-input v-model="formStock.sumbillnumber" placeholder="请输入汇总单据编号"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-divider content-position="center">库存调拨单分录信息</el-divider>
        <el-table :data="omsStocktransferbillentryList" ref="omsStocktransferbillentry">
          <el-table-column type="selection" width="50" align="center"/>
          <el-table-column label="序号" align="center" prop="index" width="50"/>
          <el-table-column label="物料编码" prop="materialnumber" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.materialnumber" placeholder="请输入物料编码"/>
            </template>
          </el-table-column>
          <el-table-column label="物料名称" prop="materialname" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.materialname" placeholder="请输入物料名称"/>
            </template>
          </el-table-column>
          <el-table-column label="调出仓库编码" prop="issuewarehousenumber" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.issuewarehousenumber" placeholder="请输入调出仓库编码"/>
            </template>
          </el-table-column>
          <el-table-column label="调出仓库名称" prop="issuewarehousename" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.issuewarehousename" placeholder="请输入调出仓库名称"/>
            </template>
          </el-table-column>
          <el-table-column label="调入仓库编码" prop="receiptwarehousenumber" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.receiptwarehousenumber" placeholder="请输入调入仓库编码"/>
            </template>
          </el-table-column>
          <el-table-column label="调入仓库名称" prop="receiptwarehousename" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.receiptwarehousename" placeholder="请输入调入仓库名称"/>
            </template>
          </el-table-column>
          <el-table-column label="计量单位" prop="unitnumber" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.unitnumber" placeholder="请输入计量单位"/>
            </template>
          </el-table-column>
          <el-table-column label="基本计量单位" prop="baseunitnumber" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.baseunitnumber" placeholder="请输入基本计量单位"/>
            </template>
          </el-table-column>
          <el-table-column label="数量" prop="qty" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.qty" placeholder="请输入数量"/>
            </template>
          </el-table-column>
          <el-table-column label="基本单位数量" prop="baseqty" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.baseqty" placeholder="请输入基本单位数量"/>
            </template>
          </el-table-column>
          <el-table-column label="计划调出日期" prop="issueplandate" width="240">
            <template slot-scope="scope">
              <el-date-picker clearable v-model="scope.row.issueplandate" type="date" value-format="yyyy-MM-dd"
                              placeholder="请选择计划调出日期"/>
            </template>
          </el-table-column>
          <el-table-column label="计划调入日期" prop="receiptplandate" width="240">
            <template slot-scope="scope">
              <el-date-picker clearable v-model="scope.row.receiptplandate" type="date" value-format="yyyy-MM-dd"
                              placeholder="请选择计划调入日期"/>
            </template>
          </el-table-column>
          <el-table-column label="是否赠品" prop="ispresent" width="150">
            <template slot-scope="scope">
              <el-select v-model="scope.row.ispresent" placeholder="请选择是否赠品">
                <el-option
                  v-for="dict in dict.type.yes_no"
                  :key="dict.value"
                  :label="dict.label"
                  :value="Number(dict.value)"
                ></el-option>
              </el-select>
            </template>
          </el-table-column>
          <el-table-column label="备注" prop="remark" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.remark" placeholder="请输入备注"/>
            </template>
          </el-table-column>
        </el-table>
      </el-form>
    </el-dialog>

    <!-- 打开其他出库单对话框 -->
    <el-dialog :title="title" :visible.sync="openOtherOut" width="1500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
        <el-row>
          <el-col :span="6">
            <el-form-item label="单据编号" prop="billnumber">
              <el-input v-model="form.billnumber" placeholder="请输入单据编号" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="业务日期" prop="bizdate">
              <el-date-picker clearable
                              style="width: 265px"
                              v-model="form.bizdate"
                              type="date"
                              value-format="yyyy-MM-dd"
                              placeholder="请选择业务日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="库存组织编码" prop="storageorgnumber">
              <el-input v-model="form.storageorgnumber" placeholder="请输入库存组织编码" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="库存组织名称" prop="storageorgname">
              <el-input v-model="form.storageorgname" placeholder="请输入库存组织名称" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="业务类型编码" prop="biztypenumber">
              <el-input v-model="form.biztypenumber" placeholder="请输入业务类型编码" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="业务类型名称" prop="biztypename">
              <el-input v-model="form.biztypename" placeholder="请输入业务类型名称" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="事务类型编码" prop="transactiontypenumber">
              <el-input v-model="form.transactiontypenumber" placeholder="请输入事务类型编码" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="事务类型名称" prop="transactiontypename">
              <el-input v-model="form.transactiontypename" placeholder="请输入事务类型名称" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="记账公司编码" prop="accountcompanynumber">
              <el-input v-model="form.accountcompanynumber" placeholder="请输入记账公司编码" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="记账公司名称" prop="accountcompanyname">
              <el-input v-model="form.accountcompanyname" placeholder="请输入记账公司名称" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="成本中心编码" prop="costcenternumber">
              <el-input v-model="form.costcenternumber" placeholder="请输入成本中心编码" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="成本中心名称" prop="costcentername">
              <el-input v-model="form.costcentername" placeholder="请输入成本中心名称" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="币别" prop="currency">
              <el-input v-model="form.currency" placeholder="请输入币别" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="汇率" prop="exchangerate">
              <el-input v-model="form.exchangerate" placeholder="请输入汇率" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="来源单据编号" prop="srcbillnumber">
              <el-input v-model="form.srcbillnumber" placeholder="请输入来源单据编号" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="传送日期" prop="transtime">
              <el-date-picker clearable
                              style="width: 265px"
                              v-model="form.transtime"
                              type="date"
                              value-format="yyyy-MM-dd"
                              placeholder="请选择传送日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>

          <el-col :span="6">
            <el-form-item label="已传EAS" prop="istrans">
              <el-select v-model="form.istrans" placeholder="请选择已传EAS">
                <el-option
                  v-for="dict in dict.type.yes_no"
                  :key="dict.value"
                  :label="dict.label"
                  :value="Number(dict.value)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="18">
            <el-form-item label="失败原因" prop="reason">
              <el-input v-model="form.reason" type="textarea" autosize />
            </el-form-item>
          </el-col>
        </el-row>

        <el-divider content-position="center">其他出库单明细信息</el-divider>
        <el-table :data="omsOtherissuebillentryList" ref="omsOtherissuebillentry">
          <el-table-column type="selection" width="50" align="center" />
          <el-table-column label="序号" align="center" prop="index" width="50"/>
          <el-table-column label="仓库编码" prop="warehousenumber" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.warehousenumber" placeholder="请输入仓库编码" />
            </template>
          </el-table-column>
          <el-table-column label="仓库名称" prop="warehousename" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.warehousename" placeholder="请输入仓库名称" />
            </template>
          </el-table-column>
          <el-table-column label="物料编码" prop="materialnumber" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.materialnumber" placeholder="请输入物料编码" />
            </template>
          </el-table-column>
          <el-table-column label="物料名称" prop="materialname" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.materialname" placeholder="请输入物料名称" />
            </template>
          </el-table-column>
          <el-table-column label="计量单位" prop="unitnumber" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.unitnumber" placeholder="请输入计量单位" />
            </template>
          </el-table-column>
          <el-table-column label="基本计量单位" prop="baseunitnumber" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.baseunitnumber" placeholder="请输入基本计量单位" />
            </template>
          </el-table-column>
          <el-table-column label="数量" prop="qty" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.qty" placeholder="请输入数量" />
            </template>
          </el-table-column>
          <el-table-column label="基本单位数量" prop="baseqty" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.baseqty" placeholder="请输入基本单位数量" />
            </template>
          </el-table-column>
          <el-table-column label="单价" prop="price" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.price" placeholder="请输入单价" />
            </template>
          </el-table-column>
          <el-table-column label="金额" prop="amount" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.amount" placeholder="请输入金额" />
            </template>
          </el-table-column>
          <el-table-column label="是否赠品" prop="ispresent" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.ispresent" placeholder="请输入是否赠品" />
            </template>
          </el-table-column>
        </el-table>
      </el-form>
    </el-dialog>

    <!-- 用户导入结算策略价格分录对话框 -->
    <el-dialog :title="excel.title" :visible.sync="excel.show" width="400px">
      <template v-show="excel.show">
        <div>
          <div class="container">
            {{ excel.upload_file || "导入" }}
            <input
              type="file"
              accept=".xls,.xlsx"
              class="upload_file"
              :value="excel.data"
              @change="readExcelsalereturnbillEntry($event)"
            />
          </div>
        </div>
      </template>
    </el-dialog>

  </div>
</template>

<script>
  import { listSalereturnbill, getSalereturnbill, delSalereturnbill, addSalereturnbill, updateSalereturnbill } from "@/api/settlementCenter/basebill/salereturnbill";
  import {
    listTransferbill,
    delDownBill,
    handlePush,
    updataUpBill,
    getDownBill,
    getDownBillInfo,
    getTransferbill,
    delTransferbill,
    addTransferbill,
    updateTransferbill
  } from "@/api/settlementCenter/basebill/transferbill";
  import XLSX from "xlsx";
  export default {
    name: "Salereturnbill",
    dicts: ['yes_no','settlement_bill_push_type','srcup_type','settlement_return_type'],
    data() {
      return {
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 子表选中数据
        checkedOmsSalereturnbillentry: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // OMS销售退货单表格数据
        salereturnbillList: [],
        // OMS销售退货单分录表格数据
        omsSalereturnbillentryList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        //时间范围
        daterangeTradecreatedat: [],
        daterangeCloseat: [],
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          code: null,
          srcsys: null,
          refordercode: null,
          sourceplatformcode:null,
          sourceordercode:null,
          sourcetype: null,
          transactiontype: null,
          tradecreatedat: null,
          salescostcentercode: null,
          salescostcentername: null,
          customercode: null,
          customername: null,
          exitwarehousecode: null,
          exitwarehousename: null,
          invoicecode: null,
          invoicename: null,
          hasnote: null,
          currency: null,
          exchangerate: null,
          createtime: null,
          iscreatebill: null,
          reason: null,
          returntype: null,
          iscreateoutbill:null
        },
        // 表单参数
        form: {},
        // 表单校验
        rules: {
        },
        // excel导入相关参数
        excel:{
          show:false,
          upload_file: "",
          data : ""
        },
        // 选中数组填充单号
        codes: [],
        // 选中数组填充单据下发状态
        iscreatbills: [],
        // 非单个禁用
        single1: true,
        // OMS调拨单下游单据
        omsDownBillList: [],
        // 销售出库单明细表格数据
        omsSaleissuebillentryList: [],
        // 库存调拨单明细表格数据
        omsStocktransferbillentryList: [],
        // 采购入库单明细表格数据
        omsPurinwarehsbillentryList: [],
        // 其他出库单明细表格数据
        omsOtherissuebillentryList: [],
        // 是否弹出下游单据层
        openDown: false,
        // 是否显示销售出弹出层
        openSal: false,
        // 是否显示采购入弹出层
        openPur: false,
        // 是否显示库存调拨单弹出层
        openStock: false,
        // 是否显示其他出库弹出层
        openOtherOut: false,
        // 销售出库表单参数
        formSal: {},
        // 采购入库表单参数
        formPur: {},
        // 库存调拨单表单参数
        formStock: {},
        // 其他出库表单参数
        formOtherOut: {},
        // 其他出库表单参数
        maps: new Map(),
        //判断下游单据是否汇总
        downBillIsSum: false,
      };
    },
    created() {
      this.getList();
    },
    methods: {
      /** 查询OMS销售退货单列表 */
      getList() {
        this.loading = true;
        this.queryParams.params = {};
        if (null != this.daterangeTradecreatedat && '' != this.daterangeTradecreatedat) {
          this.queryParams.params["beginTradecreatedat"] = this.daterangeTradecreatedat[0];
          this.queryParams.params["endTradecreatedat"] = this.daterangeTradecreatedat[1];
        }
        if (null != this.daterangeCloseat && '' != this.daterangeCloseat) {
          this.queryParams.params["beginCloseat"] = this.daterangeCloseat[0];
          this.queryParams.params["endCloseat"] = this.daterangeCloseat[1];
        }
        listSalereturnbill(this.queryParams).then(response => {
          this.salereturnbillList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      // 表单重置
      reset() {
        this.form = {
          id: null,
          code: null,
          srcsys: null,
          refordercode: null,
          sourceplatformcode:null,
          sourceordercode:null,
          sourcetype: null,
          transactiontype: null,
          tradecreatedat: null,
          closeat: null,
          salescostcentercode: null,
          salescostcentername: null,
          customercode: null,
          customername: null,
          exitwarehousecode: null,
          exitwarehousename: null,
          invoicecode: null,
          invoicename: null,
          hasnote: null,
          currency: null,
          exchangerate: null,
          createtime: null,
          iscreatebill: null,
          reason: null,
          returntype: null,
          iscreateoutbill: null,
          outreason: null
        };
        this.omsSalereturnbillentryList = [];
        this.resetForm("form");
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.daterangeTradecreatedat = [];
        this.daterangeCloseat = [];
        this.handleQuery();
      },
      //监听row-click事件，实现选中
      rowClick(row, column, event) {
        // console.log(this.ids);
        let refsElTable = this.$refs.serveTable; // 获取表格对象
        refsElTable.toggleRowSelection(row);  //如过重复选中，则取消选中
      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map(item => item.id)
        this.single = selection.length!==1
        this.multiple = !selection.length
        this.codes = selection.map(item => item.code)
        this.iscreatbills = selection.map(item => item.iscreatebill)
      },
      /** 新增按钮操作 */
      handleAdd() {
        this.reset();
        this.open = true;
        this.title = "添加OMS销售退货单";
      },
      /** 修改按钮操作 */
      handleUpdate(row) {
        this.reset();
        const id = row.id || this.ids
        getSalereturnbill(id).then(response => {
          this.form = response.data;
          this.omsSalereturnbillentryList = response.data.omsSalereturnbillentryList;
          this.open = true;
          this.title = "修改OMS销售退货单";
        });
      },
      /** 提交按钮 */
      submitForm() {
        this.$refs["form"].validate(valid => {
          if (valid) {
            this.form.omsSalereturnbillentryList = this.omsSalereturnbillentryList;
            if (this.form.id != null) {
              updateSalereturnbill(this.form).then(response => {
                this.$modal.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              });
            } else {
              addSalereturnbill(this.form).then(response => {
                this.$modal.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              });
            }
          }
        });
      },
      /** 删除按钮操作 */
      handleDelete(row) {
        const ids = row.id || this.ids;
        this.$modal.confirm('是否确认删除OMS销售退货单编号为"' + ids + '"的数据项？').then(function() {
          return delSalereturnbill(ids);
        }).then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        }).catch(() => {});
      },
      /** OMS销售退货单分录序号 */
      rowOmsSalereturnbillentryIndex({ row, rowIndex }) {
        row.index = rowIndex + 1;
      },
      /** OMS销售退货单分录添加按钮操作 */
      handleAddOmsSalereturnbillentry() {
        let obj = {};
        obj.lineno = "";
        obj.skucode = "";
        obj.skuname = "";
        obj.qty = "";
        obj.unit = "";
        obj.baseqty = "";
        obj.baseunit = "";
        obj.qualityundertakeqty = "";
        obj.qualityrefuseqty = "";
        obj.warehouseundertakeqty = "";
        obj.warehouserefuseqty = "";
        obj.warehousenoneqty = "";
        obj.confirmquantity = "";
        obj.returnwarehousecode = "";
        obj.returnwarehousename = "";
        obj.virtualreturnwarehousecode = "";
        obj.virtualreturnwarehousename = "";
        obj.customerorder = "";
        obj.despatchcargono = "";
        obj.internalordertype = "";
        obj.remark = "";
        obj.refundcreatedat = "";
        obj.notaxprice = "";
        obj.notaxamount = "";
        obj.systaxprice = "";
        obj.taxprice = "";
        obj.taxamount = "";
        obj.taxrate = "";
        obj.tax = "";
        obj.isgift = "";
        obj.occurrencedate = "";
        obj.productiondate = "";
        this.omsSalereturnbillentryList.push(obj);
      },
      /** OMS销售退货单分录删除按钮操作 */
      handleDeleteOmsSalereturnbillentry() {
        if (this.checkedOmsSalereturnbillentry.length == 0) {
          this.$modal.msgError("请先选择要删除的OMS销售退货单分录数据");
        } else {
          const omsSalereturnbillentryList = this.omsSalereturnbillentryList;
          const checkedOmsSalereturnbillentry = this.checkedOmsSalereturnbillentry;
          this.omsSalereturnbillentryList = omsSalereturnbillentryList.filter(function(item) {
            return checkedOmsSalereturnbillentry.indexOf(item.index) == -1
          });
        }
      },
      /** 复选框选中数据 */
      handleOmsSalereturnbillentrySelectionChange(selection) {
        this.checkedOmsSalereturnbillentry = selection.map(item => item.index)
      },
      /** 导出按钮操作 */
      handleExport() {
        this.download('settlementCenter/basebill/salereturnbill/export', {
          ...this.queryParams
        }, `salereturnbill_${new Date().getTime()}.xlsx`)
      },
      /** 单据头序号 */
      rowBillHeadIndex({ row, rowIndex }) {
        row.index = rowIndex + 1;
        let rowName = "",
          findRow = this.ids.indexOf(row.id);
        if (findRow !== -1) {
          rowName = "current-row ";
        }
        row.index = rowIndex + 1;
        return rowName; //也可以再加上其他类名 如果有需求的话
      },



      // 下查退出按钮
      cancelDown() {
        this.openDown = false;
      },
      /** 下游单据列表复选框选中数据 */
      handleOmsBillSelectionChange(selection) {
        this.checkedOmsTransferbillentry = selection.map(item => item.index)
        this.single1 = selection.length !== 1
      },
      /** 下查按钮操作 */
      handleGetDown(row) {
        this.maps = new Map();
        this.resetDownList();
        this.loading = true;
        const code = row.code || this.codes
        getDownBill(code[0],'销售退货').then(response => {
          console.log(response.data);
          let salBill = response.data.salBill;
          let purBill = response.data.purBill;
          let stockBill = response.data.stockBill;
          let otherOutBill = response.data.otherOutBill;
          this.downBillIsSum = response.data.sumBillNumber;
          if (salBill != null) {
            let ids = [];
            for (let i = 0; i < salBill.length; i++) {
              let objentry = {};
              objentry.billtype = '销售出库';
              objentry.billnumber = salBill[i].billnumber;
              objentry.bizdate = salBill[i].bizdate;
              objentry.sournumber = salBill[i].storageorgnumber;
              objentry.sourname = salBill[i].storageorgname;
              objentry.targetnumber = salBill[i].customernumber;
              objentry.targetname = salBill[i].customername;
              objentry.id = salBill[i].id;
              ids.push(salBill[i].id);
              objentry.sumbillnumber = salBill[i].sumbillnumber;
              this.omsDownBillList.push(objentry);
            }
            this.maps.set('销售出库', ids)
          }
          if (purBill != null) {
            let ids = [];
            for (let i = 0; i < purBill.length; i++) {
              let objentry = {};
              objentry.billtype = '采购入库';
              objentry.billnumber = purBill[i].billnumber;
              objentry.bizdate = purBill[i].bizdate;
              objentry.sournumber = purBill[i].storageorgnumber;
              objentry.sourname = purBill[i].storageorgname;
              objentry.targetnumber = purBill[i].suppliernumber;
              objentry.targetname = purBill[i].suppliername;
              objentry.id = purBill[i].id;
              ids.push(purBill[i].id);
              objentry.sumbillnumber = purBill[i].sumbillnumber;
              this.omsDownBillList.push(objentry);
            }
            this.maps.set('采购入库', ids)
          }
          if (stockBill != null) {
            let ids = [];
            for (let i = 0; i < stockBill.length; i++) {
              let objentry = {};
              objentry.billtype = '库存调拨';
              objentry.billnumber = stockBill[i].billnumber;
              objentry.bizdate = stockBill[i].bizdate;
              objentry.sournumber = stockBill[i].issuestorageorgnumber;
              objentry.sourname = stockBill[i].issuestorageorgname;
              objentry.targetnumber = stockBill[i].receiptstorageorgnumber;
              objentry.targetname = stockBill[i].receiptstorageorgname;
              objentry.id = stockBill[i].id;
              ids.push(stockBill[i].id);
              objentry.sumbillnumber = stockBill[i].sumbillnumber;
              this.omsDownBillList.push(objentry);
            }
            this.maps.set('库存调拨', ids)
          }
          if (otherOutBill != null) {
            let ids = [];
            for (let i = 0; i < otherOutBill.length; i++) {
              let objentry = {};
              objentry.billtype = '其他出库';
              objentry.billnumber = otherOutBill[i].billnumber;
              objentry.bizdate = otherOutBill[i].bizdate;
              objentry.sournumber = otherOutBill[i].storageorgnumber;
              objentry.sourname = otherOutBill[i].storageorgname;
              objentry.id = otherOutBill[i].id;
              ids.push(otherOutBill[i].id);
              objentry.sumbillnumber = otherOutBill[i].sumbillnumber;
              this.omsDownBillList.push(objentry);
            }
            this.maps.set('其他出库', ids)
          }
          if (salBill == null && purBill == null && stockBill == null && otherOutBill == null) {
            this.$modal.msgError("不存在下游单据");
          } else {
            this.openDown = true;
            this.title = "下游单据";
          }
          this.loading = false;
        });
      },
      /** 下查表格实现点击行选中 */
      rowDownClick(row, column, event) {
        let refsElTable = this.$refs.serveDown; // 获取表格对象
        refsElTable.toggleRowSelection(row);  //如过重复选中，则取消选中
      },
      /** 查看下游单据详情 */
      getRowDownBillInfo() {
        this.resetDownAll();
        const omsDownBillList = this.omsDownBillList;
        const checkedOmsTransferbillentry = this.checkedOmsTransferbillentry;
        const omsDownBillList1 = omsDownBillList.filter(function (item) {
          return checkedOmsTransferbillentry.indexOf(item.index) === 0
        });
        let row = omsDownBillList1[0];
        getDownBillInfo(row.id, row.billtype).then(response => {
          console.log(response);
          if (response.data == null) {
            this.$modal.msgError("该单据不存在");
            this.openDown = true;
            this.title = "下游单据";
          } else {
            switch (row.billtype) {
              case "其他出库":
                this.formOtherOut = response.data;
                this.omsOtherissuebillentryList = response.data.omsOtherissuebillentryList
                this.openOtherOut = true;
                this.title = "其他出库单";
                break;
              case "库存调拨":
                this.formStock = response.data;
                this.omsStocktransferbillentryList = response.data.omsStocktransferbillentryList
                this.openStock = true;
                this.title = "库存调拨单";
                break;
              case "采购入库":
                this.formPur = response.data;
                this.omsPurinwarehsbillentryList = response.data.omsPurinwarehsbillentryList
                this.openPur = true;
                this.title = "采购入库单";
                break;
              case "销售出库":
                this.formSal = response.data;
                this.omsSaleissuebillentryList = response.data.omsSaleissuebillentryList
                this.openSal = true;
                this.title = "销售出库单";
                break;
            }
          }
        });
      },
      // 下游表单重置
      resetDownAll() {
        this.formSal = {
          id: null,
          billnumber: null,
          bizdate: null,
          storageorgnumber: null,
          storageorgname: null,
          biztypenumber: null,
          biztypename: null,
          transactiontypenumber: null,
          transactiontypename: null,
          customernumber: null,
          customername: null,
          accountcompanynumber: null,
          accountcompanyname: null,
          costcenternumber: null,
          costcentername: null,
          currency: null,
          exchangerate: null,
          description: null,
          customerorderno: null,
          factorymake: null,
          srcbilltype: null,
          srcbillnumber: null,
          createtime: null,
          isoutcustomer: null,
          sumbillnumber: null,
          istrans: null,
          transtime: null,
          reason: null
        };
        this.formPur = {
          id: null,
          billnumber: null,
          bizdate: null,
          storageorgnumber: null,
          storageorgname: null,
          biztypenumber: null,
          biztypename: null,
          transactiontypenumber: null,
          transactiontypename: null,
          suppliernumber: null,
          suppliername: null,
          accountcompanynumber: null,
          accountcompanyname: null,
          costcenternumber: null,
          costcentername: null,
          currency: null,
          exchangerate: null,
          description: null,
          srcbilltype: null,
          srcbillnumber: null,
          createtime: null,
          sumbillnumber: null
        };
        this.formStock = {
          id: null,
          billnumber: null,
          bizdate: null,
          biztypenumber: null,
          biztypename: null,
          issuestorageorgnumber: null,
          issuestorageorgname: null,
          receiptstorageorgnumber: null,
          receiptstorageorgname: null,
          outcostcenternumber: null,
          outcostcentername: null,
          outaccountcompanynumber: null,
          outaccountcompanyname: null,
          incostcenternumber: null,
          incostcentername: null,
          inaccountcompanynumber: null,
          inaccountcompanyname: null,
          currency: null,
          exchangerate: null,
          description: null,
          srcbilltype: null,
          srcbillnumber: null,
          createtime: null,
          sumbillnumber: null
        };
        this.formOtherOut = {
          id: null,
          billnumber: null,
          bizdate: null,
          storageorgnumber: null,
          storageorgname: null,
          biztypenumber: null,
          biztypename: null,
          transactiontypenumber: null,
          transactiontypename: null,
          accountcompanynumber: null,
          accountcompanyname: null,
          costcenternumber: null,
          costcentername: null,
          currency: null,
          exchangerate: null,
          srcbilltype: null,
          srcbillnumber: null,
          createtime: null,
          istrans: null,
          transtime: null,
          reason: null
        };
        this.omsSaleissuebillentryList = [];
        this.omsOtherissuebillentryList = [];
        this.omsStocktransferbillentryList = [];
        this.omsPurinwarehsbillentryList = [];
      },
      //下游单据列表重置
      resetDownList(){
        this.omsDownBillList = [];
      },
      // 删除所有下游单据
      delAllDown() {
        let that = this;
        this.$confirm("是否确定删除所有下游单据?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
          distinguishCancelAndClose: true,    // 重要，设置为true才会把右上角X和取消区分开来
          closeOnClickModal: false
        }).then(function () {
          if (that.downBillIsSum) {
            that.$modal.msgError("已有下游单据被汇总，无法删除")
          } else {
            if (that.maps.get('销售出库') != null) {
              delDownBill(that.maps.get('销售出库'), '销售出库').then(response1 => {
                console.log(response1);
              });
            }
            if (that.maps.get('库存调拨') != null) {
              delDownBill(that.maps.get('库存调拨'), '库存调拨').then(response1 => {
                console.log(response1);
              });
            }
            if (that.maps.get('采购入库') != null) {
              delDownBill(that.maps.get('采购入库'), '采购入库').then(response1 => {
                console.log(response1);
              });
            }
            if (that.maps.get('其他出库') != null) {
              delDownBill(that.maps.get('其他出库'), '其他出库').then(response1 => {
                console.log(response1);
              });
            }
          }
        }).then(() => {
          if (!that.downBillIsSum) {
            that.openDown = false;
            that.$modal.msgSuccess("删除成功");
            updataUpBill(that.ids[0], '销售退货').then(response1 => {
              that.getList();
            });
          }
        }).catch(() => {
        });
      },
      /** 下发按钮操作 */
      StartPush(row) {
        const ids = row.id || this.ids;
        this.$modal.confirm("是否确认下发？").then(function () {return handlePush(ids, '销售退货')})
          .then(response => {
          if (response.data === 0) {
            this.$modal.msgError("下发失败");
          } else {
            const iscreatbills = row.iscreatbill || this.iscreatbills;
            let numbers = '';
            let numberssize = 0;
            for (let i = 0; i < iscreatbills.length && (iscreatbills[i] === 1 || iscreatbills[i]===-2); i++) {
              numbers += this.codes[i] + ",";
              numberssize += 1;
            }
            if (numberssize === ids.length) {
              this.$modal.msgError("选中的单据都无需下发");
            } else if(numberssize === 0){
              this.$modal.msgSuccess("执行下发操作成功");
              this.getList();
            } else {
              this.$modal.msgSuccess("无需下发的单据有" + numbers + "其余单据已完成下发操作");
              this.getList();
            }
          }
        });
      },
      //下载分录模板
      importTemplate() {
        this.download('settlementCenter/basebill/salereturnbill/importTemplateEntry', {
        }, `salereturnbillEntry_template_${new Date().getTime()}.xlsx`)
        // importTemplate().then(response => {
        //   this.download(response.msg);
        // });
      },
      // 点击进行导入
      importExcelsalereturnbillEntry() {
        this.excel.upload_file = "";
        this.excel.data = "";
        this.excel.show = true;
      },
      //解析导入的excel文件
      readExcelsalereturnbillEntry(e) {
        // 读取表格文件
        // console.log("读取表格文件")
        let that = this;
        const files = e.target.files;
        if (files.length <= 0) {
          return false;
        } else if (!/\.(xls|xlsx)$/.test(files[0].name.toLowerCase())) {
          this.$message({
            message: "上传格式不正确，请上传xls或者xlsx格式",
            type: "warning"
          });
          return false;
        } else {
          // 更新获取文件名
          that.excel.upload_file = files[0].name;
          // console.log("that.excel.upload_file = files[0].name;")
        }

        const fileReader = new FileReader();
        // console.log("new FileReader();")
        fileReader.onload = ev => {
          try {
            const data = ev.target.result;
            // console.log("const data = ev.target.result;")
            const workbook = XLSX.read(data, {
              type: "binary"
            });
            // console.log("XLSX.read")
            const wsname = workbook.SheetNames[0]; //取第一张表
            // console.log("//取第一张表")
            const ws = XLSX.utils.sheet_to_json(workbook.Sheets[wsname]); //生成json表格内容
            // console.log("//生成json表格内容")

            // 从解析出来的数据中提取相应的数据
            ws.forEach(item => {
              this.omsSalereturnbillentryList.push({
                lineno : item["项次"],
                skucode : item["商品编号"],
                skuname : item["商品名称"],
                qty : item["售后数量"],
                unit : item["计量单位编码"],
                baseqty : item["基本售后数量"],
                baseunit : item["基本计量单位"],
                qualityundertakeqty : item["品控承担数量"],
                qualityrefuseqty : item["品控拒绝处理数量"],
                warehouseundertakeqty : item["仓库承担待收数量"],
                warehouserefuseqty : item["仓库拒绝处理数量"],
                warehousenoneqty : item["仓库承担无实物数量"],
                confirmquantity : item["确认数量"],
                returnwarehousecode : item["退入仓库编码"],
                returnwarehousename : item["退入仓库名称"],
                virtualreturnwarehousecode : item["虚拟退货仓库编码"],
                virtualreturnwarehousename : item["虚拟退货仓库名称"],
                customerorder : item["客户订单号"],
                despatchcargono : item["装车单号"],
                internalordertype : item["售后类型"],
                remark : item["备注"],
                refundcreatedat : item["售后日期"],
                notaxprice : item["不含税单价"],
                notaxamount : item["不含税总金额"],
                systaxprice : item["系统含税单价"],
                taxprice : item["含税单价"],
                taxamount : item["含税总金额"],
                taxrate : item["税率"],
                tax : item["税额"],
                isgift : item["是否赠品"],
                occurrencedate : item["发生日期"],
                productiondate : item["生产日期"],
              });
            });
            // this.excel.data = "";
            // 结束解析动画
            // excel.upload_file = "";
            this.excel.show = false;
          } catch (e) {
            return false;
          }
        };
        fileReader.readAsBinaryString(files[0]);
      }
    }
  };
</script>
